<?php

namespace App\Http\Controllers\user;

use App\Dao\AddressDao;
use App\Dao\AreaDao;
use App\Services\Code;

class AddressController extends BaseController
{

    public static function add_address(): array
    {
        $params =array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        AddressDao::add_address($params);
        return Code::message('',200);
    }


    public static function update_address(): array
    {
        $params =array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        AddressDao::update_address($params);
        return Code::message('',200);
    }

    public static function del_address(): array
    {
        $params =array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        AddressDao::del_address($params);
        return Code::message('',200);
    }

    public static function address(): array
    {
        $params =array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);

        return Code::message('',200,AddressDao::address($params));
    }

    public function set_default(): array
    {
        $params =array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        AddressDao::set_default($params);
        return Code::message('',200);
    }


    public function areas()
    {
        return Code::message('',200,AreaDao::areasChild(['level'=>1]));
    }


}
